package com.ruoyi.smartHighway.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.Seq;
import com.ruoyi.system.service.ISysConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.smartHighway.mapper.InspectionTaskMapper;
import com.ruoyi.smartHighway.domain.InspectionTask;
import com.ruoyi.smartHighway.service.IInspectionTaskService;

/**
 * 巡查任务信息Service业务层处理
 * 
 * @author ljj
 * @date 2024-08-01
 */
@Service
public class InspectionTaskServiceImpl implements IInspectionTaskService {

    private static final Logger logger = LoggerFactory.getLogger(InspectionTaskServiceImpl.class);

    @Autowired
    private ISysConfigService configService;

    @Autowired
    private InspectionTaskMapper inspectionTaskMapper;

    /**
     * 查询巡查任务信息
     * 
     * @param taskId 巡查任务信息主键
     * @return 巡查任务信息
     */
    @Override
    public InspectionTask selectInspectionTaskByTaskId(Long taskId) {
        return inspectionTaskMapper.selectInspectionTaskByTaskId(taskId);
    }

    /**
     * 查询巡查任务信息列表
     * 
     * @param inspectionTask 巡查任务信息
     * @return 巡查任务信息
     */
    @Override
    public List<InspectionTask> selectInspectionTaskList(InspectionTask inspectionTask){
        String fk_dataSync_url = configService.selectConfigByKey("fk_dataSync_url");
        logger.info("fk_dataSync_url:" + fk_dataSync_url);
        return inspectionTaskMapper.selectInspectionTaskList(inspectionTask);
    }

    /**
     * 新增巡查任务信息
     * 
     * @param inspectionTask 巡查任务信息
     * @return 结果
     */
    @Override
    public int insertInspectionTask(InspectionTask inspectionTask) {
        inspectionTask.setCreateTime(DateUtils.getNowDate());
        inspectionTask.setCreateBy(SecurityUtils.getLoginUser().getUsername());
        String taskCode = Seq.getId(Seq.taskCodeType);
        inspectionTask.setTaskCode(taskCode);
        return inspectionTaskMapper.insertInspectionTask(inspectionTask);
    }

    /**
     * 修改巡查任务信息
     * 
     * @param inspectionTask 巡查任务信息
     * @return 结果
     */
    @Override
    public int updateInspectionTask(InspectionTask inspectionTask) {
        inspectionTask.setUpdateTime(DateUtils.getNowDate());
        inspectionTask.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
        return inspectionTaskMapper.updateInspectionTask(inspectionTask);
    }

    /**
     * 批量删除巡查任务信息
     * 
     * @param taskIds 需要删除的巡查任务信息主键
     * @return 结果
     */
    @Override
    public int deleteInspectionTaskByTaskIds(Long[] taskIds) {
        return inspectionTaskMapper.deleteInspectionTaskByTaskIds(taskIds);
    }

    /**
     * 删除巡查任务信息信息
     * 
     * @param taskId 巡查任务信息主键
     * @return 结果
     */
    @Override
    public int deleteInspectionTaskByTaskId(Long taskId) {
        return inspectionTaskMapper.deleteInspectionTaskByTaskId(taskId);
    }
}
